home *** CD-ROM | disk | FTP | other *** search
- property allBalloonInfoList, balloonList, balloonMasterList, defaultBalloonTextSize, balloonMemberList, cBalloonType, cBalloonTypeSize, previousBalloonString, lineHiteDiff, lineStopList, lineMax, activeLine, theSelection, softReturnsList, cBalloonString, activeField, vLocOffset, sndToPlay
- global gObj1, gObj2, gObj5, gItemSeparator, gPlatForm
-
- on new me
- if not count(the windowList) then
- set allBalloonInfoList to [[9: [[13, -2], [21, 31, -4, [410, 414]]], 7: [[9, -1], [16, 22, -2, [404, 404, 408]]], 5: [[7, 0], [12, 17, 0, [418, 418, 418, 418]]], #offset: point(13, 15)], [9: [[11, -2], [21, 26, -4, [120, 142, 88]]], 7: [[8, -2], [16, 21, 0, [88, 130, 128, 98]]], 5: [[7, -2], [12, 17, -3, [92, 124, 130, 118, 66]]], #offset: point(2, 9)], [9: [[10, 0], [21, 24, -1, [124, 200, 202, 132]]], 7: [[8, 0], [16, 20, 0, [126, 178, 202, 190, 130]]], 5: [[7, 0], [12, 17, 0, [118, 196, 210, 216, 186, 120]]], #offset: point(2, 12)], [9: [[11, -1], [21, 25, 0, [206, 288, 294, 284, 204]]], 7: [[9, -2], [16, 21, -3, [202, 274, 308, 304, 262, 176]]], 5: [[8, -2], [12, 18, -4, [206, 266, 298, 312, 298, 270]]], #offset: point(2, 14)], [9: [[12, 0], [21, 28, 0, [94, 128, 126]]], 7: [[9, -1], [16, 22, -3, [102, 134, 128, 96]]], 5: [[7, -2], [12, 17, -4, [112, 146, 146, 120, 112]]], #offset: point(4, 22)], [9: [[10, 0], [21, 25, 0, [112, 192, 222, 146]]], 7: [[8, -1], [16, 19, -3, [124, 190, 218, 170, 144]]], 5: [[8, -2], [12, 19, -5, [126, 192, 228, 208]]], #offset: point(2, 19)], [9: [[11, 0], [21, 27, 0, [128, 258, 288, 266, 148]]], 7: [[9, -2], [16, 22, -3, [142, 264, 306, 302, 274, 136]]], 5: [[8, -2], [12, 18, -4, [144, 254, 280, 298, 290, 276, 146]]], #offset: point(6, 22)]]
- else
- set balloonMasterList to scanForBalloons(me)
- set balloonList to duplicate(balloonMasterList)
- end if
- set defaultBalloonTextSize to 1
- return me
- end
-
- on scanForBalloons me
- set allBalloonInfoList to []
- set balloonMemberList to []
- set bList to []
- set end to min(3000, the number of castMembers of castLib 3)
- repeat with i = 2000 to end
- if the name of member i of castLib 3 starts "b." then
- set balloonType to value(char 3 to length(the name of member i of castLib 3) of the name of member i of castLib 3)
- if balloonType and integerp(balloonType) then
- set bID to i + 8 + (balloonType * 10)
- set subList to [bID, bID + 4, bID + 8]
- add(bList, duplicate(subList))
- add(allBalloonInfoList, getData(script i of castLib 3))
- add(balloonMemberList, i)
- end if
- end if
- end repeat
- if not count(bList) then
- alert("No balloons found!")
- end if
- return bList
- end
-
- on updateBalloonContents me, theSprite
- set balloonID to the balloonID of sprite(theSprite)
- set inputTxt to getAt(getAt(the balloonProps of sprite(theSprite), 4), 2)
- if not gPlatForm then
- set the media of member (balloonID + 2) of castLib 3 to the media of member (balloonID + 2) of castLib 3
- end if
- set the text of member (balloonID + 2) of castLib 3 to inputTxt
- set the textSize of member (balloonID + 2) of castLib 3 to getAt(the balloonProps of sprite(theSprite), 1)
- set the textHeight of member (balloonID + 2) of castLib 3 to getAt(the balloonProps of sprite(theSprite), 2)
- set the scrollTop of member (balloonID + 2) of castLib 3 to getAt(the balloonProps of sprite(theSprite), 3)
- end
-
- on editText me, fromDialog, theProps, newDefault
- if not fromDialog then
- set theBalloon to getAt(the theSelection of gObj1, 1)
- set theTxt to getAt(the balloonProps of sprite(theBalloon), 4)
- set theSize to getAt(the balloonProps of sprite(theBalloon), 1)
- set dialogNum to 20 + the isBalloon of sprite(theBalloon)
- tell window 1
- displayDialog(dialogNum, theTxt, theSize)
- end tell
- puppetSound(1, "editBalloon")
- else
- set the documentTouched of gObj5 to 1
- set theBalloon to getAt(the theSelection of gObj1, 1)
- set the balloonProps of sprite(theBalloon) to theProps
- updateBalloonContents(me, theBalloon)
- set defaultBalloonTextSize to newDefault
- end if
- end
-
- on getDefaultBalloonProps me, balloonType
- set propList to duplicate(getAt(getAt(getAt(allBalloonInfoList, balloonType), defaultBalloonTextSize), 1))
- addAt(propList, 1, getPropAt(getAt(allBalloonInfoList, balloonType), defaultBalloonTextSize))
- add(propList, [" ", " "])
- return propList
- end
-
- on prepareDlog me, num, contents, size
- set cBalloonType to num
- set cBalloonString to getAt(contents, 1)
- set previousBalloonString to cBalloonString
- set cBalloonTypeSize to findPos(getAt(allBalloonInfoList, cBalloonType), size)
- set activeField to cBalloonType + 70
- initBalloon(me, cBalloonTypeSize)
- cutLines(me, 1)
- end
-
- on initBalloon me, typeSize
- set cBalloonTypeSize to typeSize
- set activeLine to 1
- set softReturnsList to [:]
- set bigFieldPropList to getAt(getAt(getAt(allBalloonInfoList, cBalloonType), typeSize), 2)
- set the textSize of member activeField to getAt(bigFieldPropList, 1)
- if not gPlatForm then
- set the media of member activeField to the media of member activeField
- end if
- set the textSize of member 12 to getAt(bigFieldPropList, 1)
- set the textHeight of member activeField to getAt(bigFieldPropList, 2)
- set lineHiteDiff to the textHeight of member 12 - getAt(bigFieldPropList, 2)
- set selectionOffset to rect(0, lineHiteDiff, 0, lineHiteDiff)
- set vLocOffset to getAt(bigFieldPropList, 3)
- if the frame > 20 then
- beginSprite(sprite(10))
- updateStage()
- end if
- set lineStopList to getAt(bigFieldPropList, 4)
- set lineMax to count(lineStopList)
- set theSelection to [length(cBalloonString)]
- set the text of member 12 to cBalloonString
- end
-
- on cutLines me, deleteChars
- set end to count(lineStopList)
- set processTxt to EMPTY
- set softReturnsList to [:]
- set tempBalloonString to cBalloonString
- repeat with i = 1 to lineMax + 1
- if tempBalloonString = EMPTY then
- exit repeat
- end if
- put tempBalloonString into field 12
- set rightLoc to getAt(lineStopList, min(i, lineMax))
- set rOffset to locToCharPos(member 12, point(rightLoc, 5)) + 1
- set thisline to char 1 to rOffset of tempBalloonString
- set containsReturn to offset("", thisline)
- if containsReturn then
- if containsReturn = 1 then
- set thisline to RETURN
- delete char 1 of tempBalloonString
- else
- set thisline to char 1 to containsReturn - 1 of thisline & RETURN
- delete char 1 to containsReturn of tempBalloonString
- end if
- else
- if the locH of charPosToLoc(member 12, length(tempBalloonString)) < getAt(lineStopList, min(i, lineMax)) then
- delete char 1 to rOffset of tempBalloonString
- else
- repeat with s = length(thisline) down to 1
- if offset(char s of thisline, " ,-") then
- exit repeat
- end if
- end repeat
- if s > 1 then
- set xOffset to char s of thisline = " "
- set thisline to char 1 to s - xOffset of thisline
- delete char 1 to s of tempBalloonString
- if not xOffset then
- addProp(softReturnsList, length(processTxt), i)
- end if
- else
- delete char 1 to rOffset of tempBalloonString
- addProp(softReturnsList, length(processTxt), i)
- end if
- end if
- end if
- put thisline into line i of processTxt
- end repeat
- if (the number of lines in processTxt > lineMax) and not deleteChars then
- set theSelection to theSelection - 1
- set cBalloonString to previousBalloonString
- set the text of member 12 to cBalloonString
- puppetSound(1, "fieldFull")
- else
- if not voidp(sndToPlay) then
- puppetSound(1, sndToPlay)
- end if
- put line 1 to lineMax of processTxt into field activeField
- set sndToPlay to 0
- end if
- end
-
- on keyCheck me, key
- set checkNum to charToNum(key)
- case checkNum of
- 8:
- if count(theSelection) = 2 then
- delete char max(1, getAt(theSelection, 1)) to getAt(theSelection, 2) of cBalloonString
- deleteAt(theSelection, 2)
- set deleteChars to 1
- set theSelection to theSelection - 1
- else
- if getAt(theSelection, 1) > 0 then
- delete char getAt(theSelection, 1) of cBalloonString
- set theSelection to theSelection - 1
- set deleteChars to 1
- end if
- end if
- set sndToPlay to "deleteKey"
- 28:
- 29:
- 30:
- 31:
- 127:
- puppetSound(1, "deleteKey")
- delete char getAt(theSelection, 1) + 1 of cBalloonString
- set deleteChars to 1
- 3:
- handleDefaultKeyDown(script 1)
- exit
- 1, 2, 4:
- otherwise:
- set previousBalloonString to cBalloonString
- if count(theSelection) = 2 then
- set sndToPlay to "key" & random(3)
- if the key = RETURN then
- set sndToPlay to "carriageReturn"
- put numToChar(4) into char max(1, getAt(theSelection, 1)) to getAt(theSelection, 2) of cBalloonString
- else
- put key into char max(1, getAt(theSelection, 1)) to getAt(theSelection, 2) of cBalloonString
- end if
- deleteAt(theSelection, 2)
- set deleteChars to 1
- else
- if the key = RETURN then
- if activeLine = lineMax then
- exit
- end if
- if getAt(theSelection, 1) = 0 then
- put numToChar(4) before char getAt(theSelection, 1) of cBalloonString
- else
- put numToChar(4) after char getAt(theSelection, 1) of cBalloonString
- end if
- set theSelection to theSelection + 1
- set sndToPlay to "carriageReturn"
- else
- if getAt(theSelection, 1) = 0 then
- put key before char getAt(theSelection, 1) of cBalloonString
- else
- put key after char getAt(theSelection, 1) of cBalloonString
- end if
- set sndToPlay to "key" & random(3)
- set theSelection to theSelection + 1
- end if
- end if
- end case
- repeat with i = 1 to 7
- set the locH of sprite (20 + i) to 9000
- end repeat
- updateStage()
- set the text of member 12 to cBalloonString
- cutLines(me, deleteChars)
- updateInsertion()
- end
-
- on updateInsertion me
- updateInsertion(sprite(10))
- end
-
- on changeTypeSize me, theSprite, newSize
- clearSelection(sprite(10), 0)
- repeat with i = 1 to 3
- if (i + 30) = theSprite then
- disable(sprite(30 + i))
- next repeat
- end if
- enable(sprite(30 + i))
- end repeat
- updateStage()
- set the text of member activeField to " "
- initBalloon(me, newSize)
- cutLines(me, 1)
- updateInsertion()
- end
-
- on convert me, input, cutOffChar
- repeat while offset(cutOffChar, input)
- put "@" into char offset(cutOffChar, input) of input
- end repeat
- return input
- end
-